<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui">

<h:head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>mymsgro</title>
	<link rel="stylesheet" type="text/css" href="css/main.css" />
	<link rel="stylesheet" type="text/css" href="css/meniu.css" />
	<link rel="stylesheet" type="text/css" href="css/style.css" />
</h:head>

<h:body>
	<ui:include src="header.xhtml" />

	<h:panelGroup layout="block" id="content">

		<ui:include src="leftMenu.xhtml" />

		<h:panelGroup layout="block" id="contenRight">

			<h:panelGroup layout="block" id="header" style="margin-top: 20px;">
				<ul>
					<li id="selected"><a>Add Candidate</a></li>
				</ul>
			</h:panelGroup>

			<h:panelGroup layout="block" id="contentTab">

			<f:event type="preRenderView" listener="#{candidateBean.preRenderView}"/>
				<h:form id="upload" enctype="multipart/form-data">
					<h:panelGrid columns="3">

						<h:outputText value="FirstName" style="float: right" />
						<h:inputText id="firstnameID" style="width: 92%;"
							value="#{candidateBean.candidateDTO.firstname}" required="true"
							requiredMessage="Please insert firtsname" />

						<h:message for="firstnameID" style="color:red"></h:message>

						<h:outputText value="LastName" style="float: right" />
						<h:inputText id="lastnameID" style="width: 92%;"
							value="#{candidateBean.candidateDTO.lastname}" required="true"
							requiredMessage="Please insert lastname" />
						<h:message for="lastnameID" style="color:red"></h:message>

						<h:outputText value="Birth date" style="float: right" />
						<p:calendar effect="explode"
							value="#{candidateBean.candidateDTO.birthdate}"
							readonlyInput="true" timeZone="#{calendarBean.timeZone}"
							navigator="true" mindate="1900-01-01"
							maxdate="#{calendarBean.dateNow}" required="true"
							requiredMessage="Can't be blank"
							yearRange="1914:#{calendarBean.dateNow}" pattern="yyyy-MM-dd"
							id="popupButtonCal1" />
						<h:message for="popupButtonCal1" style="color:red" />


						<h:outputText value="Applying for" style="float: right" />
						<h:inputText id="applyingforID" style="width: 92%;"
							value="#{candidateBean.candidateDTO.applyingFor}" required="true"
							requiredMessage="Please insert applying for" />
						<h:message for="applyingforID" style="color:red"></h:message>

						<h:outputText value="Domain" style="float: right" />
						<h:inputText id="domainID" style="width: 92%;"
							value="#{candidateBean.candidateDTO.domain}" required="true"
							requiredMessage="Please insert domain" />
						<h:message for="domainID" style="color:red"></h:message>

						<h:outputText value="Phone" style="float: right" />
						<h:inputText id="phoneID" style="width: 92%;"
							value="#{candidateBean.candidateDTO.phoneNr}" required="true"
							requiredMessage="Please insert phone number" />
						<h:message for="phoneID" style="color:red"></h:message>

						<h:outputText value="Email" style="float: right" />
						<h:inputText id="emailID" style="width: 92%;"
							value="#{candidateBean.candidateDTO.email}" required="true"
							validatorMessage="Email address is not valid"
							requiredMessage="Please insert email">
							<f:validateRegex
								pattern="[\w\.-]*[a-zA-Z0-9_]@[\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]" />
						</h:inputText>
						<h:message for="emailID" style="color:red"></h:message>

						<h:outputText id="cv" value="CV" style="float: right" />

						<h:inputFile id="uploadFile" name="uploadFile"
							validator="#{candidateBean.validate}">
						</h:inputFile>
						<h:outputText></h:outputText>
						
						<h:outputText value="Photo:" style="float: right" />
						<p:fileUpload fileUploadListener="#{candidateBean.photoSave}"
							mode="advanced" dragDropSupport="false" multiple="true"
							update="messages" sizeLimit="1000000" fileLimit="3"
							allowTypes="/(\.|\/)(gif|jpe?g|png)$/" />
						<p:growl id="messages" showDetail="true" />
						<h:outputText></h:outputText>
						<h:outputText></h:outputText>
						
						<h:outputText value="#{candidateBean.errorMess}" style="color:red" />

						<h:outputText />
						<h:commandButton id="buttonSave" value="Add"
							styleClass="buttonCandidate"
							actionListener="#{candidateBean.createCandidate}">
							<f:attribute name="firstname"
								value="#{candidateBean.candidateDTO.firstname}" />
							<f:attribute name="lastname"
								value="#{candidateBean.candidateDTO.lastname}" />
							<f:attribute name="email"
								value="#{candidateBean.candidateDTO.email}" />
						</h:commandButton>

						<h:outputText value="#{candidateBean.errorMessAdd}"
							style="color:red" />


					</h:panelGrid>
				</h:form>

			</h:panelGroup>
		</h:panelGroup>
	</h:panelGroup>

</h:body>
</html>